<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>student register</title>
<script src="./resource/js/jquery-3.1.0.js"></script>
	<script src="./resource/bootstrap-3.3.0/js/bootstrap.js"></script>
	<script src="./resource/js/jquery.uploadifive.min.js"></script>

	<link href="./resource/bootstrap-3.3.0/css/bootstrap.css"
		  rel="stylesheet">
	<link href="./resource/bootstrap-3.3.0/css/bootstrap-theme.css"
		  rel="stylesheet">
	<link href="./resource/js/uploadifive.css"
		  rel="stylesheet">
		  <style>
        body{
            padding-left:10%;
            padding-right:10%;
            padding-bottom:3%;
            padding-top:3%;
            font-family:"Trebuchet MS", Arial, Helvetica, sans-serif;
        }
        a{
            text-decoration:none;
        }
    </style>
</head>
<body>
<form onsubmit="return false" id="addMerchantForm" class="form-horizontal merchantRegist" enctype="multipart/form-data"  >
    <div class="form-group">
        <label   class="col-sm-3 control-label">account</label>
        <div class="col-sm-6">
            <input type="text" class="form-control" id="name" ng-model="studentName"
                   onkeyup="avoidDouble()"   required="required"  placeholder="your account">
        </div>
    </div>
    <div align="center">
        <div id="accountInfo" ng-bind="studentNameInfo"></div>
    </div>
    <div class="form-group">
        <label  class="col-sm-3 control-label">password</label>
        <div class="col-sm-6">
            <input type="password" class="form-control" id="studentPsd" ng-model="studentPassword"
                   required="required"  placeholder="your password">
        </div>
    </div>
    <div class="form-group">
        <label  class="col-sm-3 control-label">confirm</label>
        <div class="col-sm-6">
            <input type="password" class="form-control" id="confirmPsd" ng-model="studentConfirmPsd"
                   required="required"    placeholder="confirm your password">
        </div>
    </div>
    <div class="form-group">
        <label  class="col-sm-3 control-label">descripe</label>
        <div class="col-sm-6">
            <input type="text" class="form-control" id="descripe" ng-model="studentRemark"
                   required="required"    placeholder="descripe">
        </div>
    </div>
    <div class="form-group">
        <label  class="col-sm-3 control-label">phone</label>
        <div class="col-sm-6">
            <input type="number" class="form-control" id="phone" ng-model="studentPhone"
                   required="required"    placeholder="your phone number">
        </div>
    </div>
    <div class="form-group">
        <label  class="col-sm-3 control-label">gender</label>
        <label>
            <input type="radio" name="gender"   value='male' checked>male
        </label>
        <label>
            <input type="radio" name="gender"  value='female' checked>female
        </label>
    </div>
    <div class="form-group">
        <div class="col-sm-offset-3 col-sm-3">
            <button id="summitMerchantInfo" ng-disabled="stopAdd" onclick="addStudent()" data-toggle="modal" data-target="#myModal" class="btn btn-warning">register</button>
            <a href="studentLogin.html"><h4>登录</h4></a>
        </div>
        <div>

        </div>
    </div>
    <div class="form-group" align="center">
        <div id="alertInfo"></div>
    </div>
</form>
</body>
<script type="text/javascript">
	function avoidDouble() {
        var data={"name":$("#name").val()}; 
    
        $.ajax("studentName",{
            method:'GET',
            type:'json',
            data:data,
            success:function (result) {
               if(result=='exist'){
            	   $("#summitMerchantInfo").attr('disabled',true);
            	   $('#accountInfo').text("The name has exist");
            	  
               }else{
            	   $("#summitMerchantInfo").attr('disabled',false);
            	   $('#accountInfo').text("")
            	    
               }
            }
        })
        
    } 
	function addStudent(){ 
		if($("#studentPsd").val()==$("#confirmPsd").val()){
			var data={"name":$("#name").val(),"password":$('#studentPsd').val(),"gender":$('input[name="gender"]:checked').val(),"remark":$("#descripe").val(),"phone":$("#phone").val()};
			$.ajax("student",{
				method:"POST",
				type:'json',
				data:data,
				success:function(result){
					
                  alert('注册成功');
                  window.location.href="studentLogin.html";
                    
				}
			})
		}else{
			$("#alertInfo").text("密码不匹配");
		}
	}
		
		
	
</script>
</html>